<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
%>
<jsp:include page="/comm/header.jsp" />
<script type="text/javascript">
	var forwardUrl = ""; 

	$(function(){
		$("#login").click(doSubmit);
				
		$("#pwd").bind('keyup',function(event) {
			if(event.keyCode==13){
				doSubmit();
			}
		});
	});
	
	var doSubmit = function(){
		var mail = $("#mail").val();
		var pwd = $("#pwd").val();
		
		if(!mail && !pwd){
			$("#responsemsg").html("<font color='red'>请输入您的登录邮箱和密码</font>");
			return;
		}
		
		if(!mail){
			$("#responsemsg").html("<font color='red'>请输入您的登录邮箱</font>");
			return;
		}
		
		if(!pwd){
			$("#responsemsg").html("<font color='red'>请输入您的密码</font>");
			return;
		}
		
		if(validLogin(mail, pwd)){
			if (forwardUrl != "") {
				window.location.href= forwardUrl;
			}
			else {
				window.location.href = "myhome.htm";		
			}
		}
	};
	
	var validLogin = function(mail, pwd){
		var flag = false;
		$.ajax({
			type:"POST",
			url:"aLogin.htm",
			async: false,
			data:{email:mail, pwd:pwd},
			datatype:"text",
			success:function(data){
				if(data == ""){
					$("#responsemsg").html("<font color='red'>用户名或者密码错误!</font>");
				}else{
					flag = true;
					var array = data.split("|");
					if (array.length == 4) {
						forwardUrl = array[3];
					}
				}
		    }
		});
		return flag;
	};

</script>

<div class="clear"></div>
  
<!--第1部分开始  --> 
    <div class="wrap1">
    	<div class="blank1"></div>
        <div class="login_box">
       		  <div class="wrap_left">
                
               	<div class="login_pic"></div>
                  <span class="span36">欢迎您登录代购岛，这里有世界各地的经纪人为您提供无忧代购服务! </span>
                    
                </div>
                <form name="form1" method="post">
            	<div class="wrap_left">
            		<div class="login_box_li">
                    	<div class="w">
                    	<ul>
                            <div id="responsemsg" align="center"></div>
                        	<li class="t1">登录邮箱：</li>
                            <li class="t2"><input id="mail" name="userModel.email" type="text" class="input1" /></li>
                            <div class="clear"></div>
                            
                        	<li class="t1">密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码：</li>
                            <li class="t2"><input id="pwd" name="userModel.password" type="password" class="input1" /></li>
                            <div class="clear"></div>
                            
                            <div class="clear"></div>
                            
                        </ul>
                        <div class="login_but"><input type="button" class="login" id="login" value="登&nbsp;&nbsp;录" style="cursor:pointer"/></div>
<a href="<%=path%>/retrievepassword.htm" style="margin-left:75px;"><span class="span_wjmm">忘记密码了？</span></a>
<a href="<%=path%>/new_register.htm"><span class="span_ljzc">立即注册</span></a>
                        </div>
                    </div>
                    
           		</div>
           		</form>
            	<div class="clear"></div>
       </div>

   </div>
<!--第1部分结束  --> 
<jsp:include page="/comm/bottom.jsp" />
